package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;

import com.itheima.SysLogService;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/sysLog")
public class SysLogController {
    @Reference
    private SysLogService sysLogService;
    @RequestMapping("/findPage")
    public Result findPage(@RequestBody QueryPageBean queryPageBean) {
        try {
            PageResult pageResult = sysLogService.findPage(queryPageBean);
            return Result.success("查询成功", pageResult);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }


    @RequestMapping("/delete")
    public Result delete(@RequestParam("id") Integer id) {
        try {
            sysLogService.delete(id);
            return Result.success("删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("删除失败");
        }
    }

}
